﻿using System;
using System.Data.OleDb;

namespace StockConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            //连接数据库
            AccessOpt.connectAccess();
            //初始化数据库
            AccessOpt.init();
            //循环选股
            for( int year = 2000; year<=2015; year++)
            {
                for( int month = 101; month<=112; month++)
                {
                    //拼接选股日期
                    string chsmnt = year.ToString() + "-" + month.ToString().Substring(1);
                    Console.WriteLine("选股:" + chsmnt + "开始>>>>>>>>>");
                    //生成选股对象
                    Stock stock = new Stock(chsmnt);
                    //得到过去6个月的个股收益率
                    AccessOpt.past(stock);
                    //选出赢家组合，并计算出后六个月的个股收益率
                    AccessOpt.winAfter(stock);
                    //得到赢家组合结果
                    decimal d = AccessOpt.getResult();
                    stock.Winrt = d;
                    //选出输家组合，并计算出后6个月的个股收益率
                    AccessOpt.loseAfter(stock);
                    //得到输家组合结果
                    decimal d2 = AccessOpt.getResult();
                    stock.Losert = d2;
                    //保存选股结果
                    AccessOpt.insertResult(stock);
                    Console.WriteLine("选股:" + chsmnt + "结束<<<<<<<<<<");
                    Console.WriteLine();
                }
            }
            AccessOpt.closeConnection();
            Console.WriteLine("操作完成，回车结束程序");
            Console.ReadLine();
        }

        
    }
}
